﻿STONE BIOS UPDATER CORE V4.2.5
==============================

Purpose
-------
Windows BIOS update utility utilising scripts, for Stone support staff, field engineers and customers.
Runtime and Capsule transaction/verification workflows are retained.
Catalogue schema validation, versioned local package storage, ZIP extraction,
and separate package/payload SHA256 validation. RC2 standardises result logging, CSV fields and exit-code semantics.
Supports Stone brand client and workstation devices who's model is listed within the published XML catalogue.

https://drivers.stonegroup.co.uk/driverfinder/BOAMOT/BIOS/FirmwareRepository/BIOS.xml

Commands
--------
Launch.bat /Update               			Check/download/validate/flash using catalogue method.
Launch.bat /Check              			 	Compare installed BIOS with approved target; no download/flash.
Launch.bat /Download            			Download and validate package/payload for detected board.
Launch.bat /DownloadAll         			Download and validate all Enabled=true, Approved entries.
Launch.bat /Status              			Show pending or most recent update transaction.
Launch.bat /Update /NoRestart   		 	Valid for Runtime only; updater itself never initiates reboot.
Launch.bat /Update /Silent      			Unattended update; no FLASH confirmation or final pause.
Launch.bat /Update /Silent /AllowCapsuleRestart		Explicit consent for ASUS Capsule firmware utility to restart immediately.

Usage
-----
Extract archive package to local storage or portable storage connected to target computer.
In a command prompt or PowerShell terminal, navigate to the package directory.
Launch the Stone BIOS Updater using one of the commands defined above, observe on screen prompts.

==============================

Local BIOS storage
------------------
The catalogue Version determines the local version directory:

Boards\<normalised-model>\<version>\

Example, extracted payload:
Boards\PRIME-A520M-A-II\3645\
    PRIME-A520M-A-II-ASUS-3645.zip
    PRIME-A520M-A-II-ASUS-3645-BOAMOT520.CAP

Example, direct ZIP payload:
Boards\PRO-Q870M-C\3212\
    Pro-Q870M-C-SI-3212-Stone.zip

The Boards directory is a persistent validated cache. Successfully downloaded and validated
BIOS versions are retained indefinitely, including versions that are no longer current in the
catalogue. Historical version directories and board directories are not automatically removed.
Known-invalid or incomplete artifacts are different: corrupt ZIPs are deleted and reacquired when
needed; corrupt extracted payloads are deleted and regenerated from a valid ZIP; failed temporary
extraction data is removed. Administrators may manually remove historical version directories if
local housekeeping or disk-space requirements make this necessary.

Package and payload processing
------------------------------
1. Resolve Boards\<Board>\<Version> from XML.
2. If the repository ZIP is cached, verify <SHA256>. Invalid cached packages are deleted.
3. If required, download <File> from <URL> and verify <SHA256> before use.
4. If <Extract>true</Extract>, extract to a temporary directory and locate exactly one file
   matching <PayloadFile>. Verify it using <PayloadSHA256>, then copy it into the version folder.
5. If <Extract>false</Extract>, <PayloadFile> must equal <File> and <PayloadSHA256> must equal
   <SHA256>. The ZIP itself is the flash payload.
6. {BIOS} in <Flash><Arguments> resolves to the fully validated payload path.
7. Temporary extraction directories are removed whether extraction succeeds or fails.

The package ZIP is always verified before an extracted CAP is trusted. A cached CAP is also
verified on every resolution. /Download, /DownloadAll and /Update use the same resolver.

Catalogue validation
--------------------
The complete catalogue is validated after download and before board processing. Validation
checks mandatory fields, permitted enum values, hashes, filenames, approved repository host,
flash tool/arguments and duplicate board models. Invalid catalogue data aborts safely before
payload download or firmware execution.

Release status controls
-----------------------
Enabled=true + Status=Approved   Normal deployment permitted.
Enabled=true + Testing           Board known, BIOS not released for normal deployment.
Enabled=true + Withdrawn         BIOS explicitly removed from normal deployment.
Enabled=false                    Board entry disabled regardless of BIOS Status.

Persistent update state
-----------------------
C:\ProgramData\Stone\BIOSUpdater\
    Logs\BIOSUpdate.log
    Logs\BIOSUpdateResults.csv
    State\PendingUpdate.json
    Results\LastUpdate.json
    VerifyUpdate.ps1

PendingVerification and VerificationRetry transactions block a new /Update. /Status can
reconcile a pending Runtime or Capsule transaction to VerifiedSuccess only when motherboard,
serial number and target BIOS all match. The startup verifier distinguishes target-not-applied,
identity mismatch and repeated verifier errors rather than treating every issue as a flash failure.

Exit codes
----------
 0  Operation completed successfully, including UpToDate/no-op results
 1  Not elevated (Launch.bat)
 2  Invalid command-line options or interactive selection
10  Unsupported board
11  BIOS package/payload download, extraction or SHA256 verification failure
12  Retired in RC2; no longer returned for UpToDate
13  Hardware/BIOS detection failed
14  Board disabled
15  BIOS not Approved
16  Operator cancelled flash
21  Catalogue retrieval/XML parse error
22  Duplicate model lookup protection
23  Missing target version
24  BIOS version comparison failure
25  DownloadAll payload processing failures
26  Catalogue schema/field validation failure
30  Missing ASUS IO driver installer
31  Driver install/verification failure
32  BitLocker status/suspension failure
40  Missing flash executable
41  Invalid flash configuration/tool/arguments
42  Unapproved alternative flash method
43  Unsupported Flash Type
44  Unable to prepare post-reboot verification
45  Unable to launch firmware utility
46  /NoRestart used with Capsule
47  Previous BIOS update still pending verification
48  ASUS firmware utility reported failure; vendor exit code is retained in transaction detail/log
50  Target BIOS not yet detected; verification will retry
51  Verification hardware identity mismatch; transaction Unverified
52  Target BIOS not applied after successful Windows verification attempts
53  Verification mechanism error (retry/final failure according to transaction state)

/Check returns 0 both when an update is required and when the BIOS is already current. The
machine-readable distinction is the RESULT text (UpdateRequired or UpToDate), not the process
exit code. /Update also returns 0 when no update is required.

Logging and results
-------------------
BIOSUpdate.log is the chronological diagnostic log for all modes. Successful and failed command
paths write an explicit RESULT and exit-code summary where applicable.

BIOSUpdateResults.csv is a firmware-update transaction ledger, not a general activity log. Routine
/Check, /Download and /DownloadAll operations do not create rows. /Update records the pending
transaction after the ASUS utility accepts the operation, and post-reboot verification records the
subsequent verification result. /Status writes a result row only when it actually reconciles a
pending transaction to VerifiedSuccess.

CSV columns:
Timestamp, ComputerName, SerialNumber, Baseboard, PreviousBIOS, TargetBIOS, DetectedBIOS,
FlashType, Status, ExitCode, Detail, TransactionId


V4.2.4 changes
------------------
- Based on the hardware-tested V4.2.4 RC1.1 package and its validated package resolver.
- Added mandatory Extract, PayloadFile and PayloadSHA256 catalogue fields.
- Repository File is now a ZIP package for every board.
- Added Boards\<Board>\<Version> versioned cache structure.
- Added automatic ZIP extraction for historical boards requiring direct CAP input.
- Added independent package and payload SHA256 validation.
- Direct-ZIP boards retain a consistent XML structure; File/PayloadFile and hashes must match.
- Added complete catalogue field/value validation before firmware operations.
- Formalised BIOS Status values: Testing, Approved, Withdrawn.
- Retained validated Runtime and Capsule post-reboot verification behaviour.

- Corrected displayed updater version to V4.2.4 RC2.
- UpToDate is now a successful no-op (exit 0); exit 12 is retired.
- /Check, /Download and /DownloadAll no longer write routine rows to BIOSUpdateResults.csv.
- Expanded the transaction CSV and added TransactionId correlation across reboot.
- Mapped non-zero ASUS flasher returns to stable Stone exit code 48 while retaining vendor detail.
- Added explicit RESULT/exit summaries to normal logging paths.
- Documented persistent-cache Option A: valid historical BIOS packages are retained indefinitely.

V4.2.5 - SILENT MODE (managed restart)
-----------------------------------------
Launch.bat /Update /Silent
  Unattended Runtime update. No confirmation or updater-initiated reboot.
  Exit 0 with PendingVerification is NOT final firmware verification.
  Managed reboot and subsequent startup verifier are required.

Launch.bat /Update /Silent /AllowCapsuleRestart
  Explicit consent for ASUS Capsule firmware utility to restart immediately.
  Without consent silent Capsule refuses with exit 49 before firmware/driver
  or BitLocker side effects. /NoRestart with Capsule remains exit 46.

Silent suppresses routine console messages but retains full file logs and
prints ERROR/WARNING/RESULT/exit-code messages. No interactive FLASH prompt
or final pause. All integrity, approval, BitLocker, driver and pending
transaction checks remain enforced. Existing successful historical BIOS
packages are retained (Option A cache policy).
